<?php
/**
 * FCommentoFoto.php
 * @author mw
 * @package Foundation
 *
 */
/**
 * FCommentoUtente
 * @author mw
 * @package Foundation
 *
 */
class FCommentoFoto extends Fdatabase {
	/**
	 * Costruttore
	 */
	public function __construct() {
		parent::__construct('ECommentoFoto','commenti_foto',array('writer','fotoid','timestamp'));
	}
	/**
	 * Query per costruire la lista dei commenti
	 * @param integer fotoid
	 * @param integer num_commenti
	 * @param integer start_commenti
	 */
	public function getCommentiFoto($fotoid,$num_commenti = 10,$start_commenti = -1) {
		
		$start;
		$end;
		
		if($start_commenti != -1){
			$start = $start_commenti;
			$end = $start_commenti + $num_commenti;
		}else {
			$start = 0;
			$end = $num_commenti;
		}
		
		$query .= 'SELECT * FROM commenti_foto WHERE commenti_foto.fotoid = '.$this->safeString($fotoid).'ORDER BY timestamp DESC
			LIMIT '.$this->safeString($start).','.$this->safeString($end).';';
			
		$this->_query($query);
	}
	
}